const merge = require('webpack-merge')
const common = require('./webpack.common.js')
const webpack = require('webpack')
const path = require('path')

module.exports = merge(common, {
    entry: {
        app: [
            'react-hot-loader/patch',
            path.join(__dirname, 'src/index.js')
        ]
    },
    output: {
        /*这里本来应该是[chunkhash]的，但是由于[chunkhash]和react-hot-loader不兼容。只能妥协*/
        filename: '[name].[hash].js'
    },
    devtool: '#inline-source-map',
    devServer: {
        contentBase: './dist',
        historyApiFallback: true,
        hot: true,
        host: "0.0.0.0",
        disableHostCheck: true,
        proxy: [{
            // "/api": "http://192.168.0.215/gitee/ceoja-weike/public"
            context: ["/api", "/wechat"],
            target: "http://192.168.0.201/project/ceoja-weike/public",
            // target: "http://ceoja-api.aosaiban.com",
        }]
    },
    module: {
        rules: [
            // {
            //     test: /\.css$/,
            //     use: [
            //         'style-loader',
            //         'css-loader',
            //         'postcss-loader'
            //     ]
            // },
            // {
            //     test: /\.less$/,
            //     use: [{
            //         loader: "style-loader"
            //     }, {
            //         loader: "css-loader"
            //     }, {
            //         loader: "less-loader", options: {
            //             strictMath: true,
            //             noIeCompat: true
            //         }
            //     }]
            // },
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin()
    ]
})